package com.qf.controller;

import com.qf.entity.TlUser;
import com.qf.service.UserService;
import com.qf.utils.QiNiuTools;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;
    @Autowired
    QiNiuTools qiNiuTools;

    /**
     * @param user 用户信息  需要用户名和密码
     * @return
     */
    //@PostMapping("/login")
    public ResultMsg login(@RequestBody TlUser user) {
        return userService.login(user.getUserName(), user.getUserPass());
    }

    @PostMapping("/regist")//注册
    public ResultMsg regist(@RequestBody TlUser user) {
        return userService.regist(user);
    }

    @GetMapping("/user")//查询当前用户的信息
    public ResultMsg user(HttpServletRequest request) {
        return userService.user(request);
    }

    @PostMapping("/registvip")//注册会员
    public ResultMsg registvip(HttpServletRequest request) {
        return userService.registvip(request);
    }

    @GetMapping("/updatetel")//修改手机号
    public ResultMsg updatetel(String userTel, HttpServletRequest request) {
        return userService.updatetel(userTel, request);
    }

    @GetMapping("/updatepass")//修改密码
    public ResultMsg updatepass(String orderpass, String newpass, HttpServletRequest request) {
        return userService.updatepass(orderpass, newpass, request);
    }

    @GetMapping("/updatemail")//修改邮箱号
    public ResultMsg updatemail(String userMail, HttpServletRequest request) {
        return userService.updatemail(userMail, request);
    }

    @GetMapping("/sendmail")//发送验证码
    public ResultMsg sendmail(String userMail) {
        return userService.usermail(userMail);
    }

    @GetMapping("/logout")//退出登录
    public ResultMsg logout(String uuid) {
        return userService.logout(uuid);
    }

    @GetMapping("/deleteuser")//注销账户
    public ResultMsg deleteuser(String uuid) {
        return userService.deleteuser(uuid);
    }

    @PostMapping("/update")
    public ResultMsg update(@RequestBody TlUser user){
        return userService.modify(user);
    }

}
